package com.yuxi.al.sort;

/**
 * Created by yuxi on 17/2/5.
 */
public class SelectSort {
    public static void main(String[] args) {
        //选择排序
        int[] arr = {2, 3, 1, 33, 2, 4, 56, 42, 3, 21, 6, 7, 5};
        selectSort(arr);
        //排序后
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(arr[i]+" ");
        }
    }

    private static void selectSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }
}
